<#assign path="${springMacroRequestContext.getContextPath()}">
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <title>课程信息管理系统</title>
    <meta name="keywords" />
    <meta name="description" />
    <meta name="author" content="DeathGhost" />
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge, chrome=1">
    <link rel="icon" href="${path}/static/images/icon/favicon.ico" type="image/x-icon">
    <link rel="stylesheet" type="text/css" href="${path}/static/css/style.css" />
    <script src="${path}/static/javascript/jquery.js"></script>
    <script src="${path}/static/javascript/plug-ins/customScrollbar.min.js"></script>
    <script src="${path}/static/javascript/plug-ins/echarts.min.js"></script>
    <script src="${path}/static/javascript/plug-ins/layerUi/layer.js"></script>
    <script src="${path}/static/editor/ueditor.config.js"></script>
    <script src="${path}/static/editor/ueditor.all.js"></script>
    <script src="${path}/static/javascript/plug-ins/pagination.js"></script>
    <script src="${path}/static/javascript/public.js"></script>
    <script src="${path}/static/javascript/menu.js"></script>
</head>
<style type="text/css">
    .kd {
        padding-left: 5px
    }

    .inputcs {
        width: 300px
    }

    .btncs {

    }
</style>
<body>
<div class="main-wrap">
    <input type="hidden" id="power222" name="power" value="${Session["power"]}" >
    <div class="side-nav">
        <div class="side-logo">
            <div class="logo">

            <span class="logo-ico"> <i class="i-l-1"></i>
					<i class="i-l-2"></i> <i class="i-l-3"></i>
					</span> <strong>课程信息管理系统</strong>
            </div>
        </div>

        <nav id="nav" class="side-menu content mCustomScrollbar" data-mcs-theme="minimal-dark">
            <h2>
                <a href="${path}/User/Main" class="InitialPage"><i class="icon-dashboard"></i>首页</a>
            </h2>
            <ul>
                <li class="open">
                    <dl>
                        <dt id="1100">
                            <i class="icon-columns"></i>基础信息管理<i class="icon-angle-right"></i>
                        </dt>
                        <dd id="1101">
                            <a href="${path}/User/teacher">教师信息管理</a>
                        </dd>
                        <dd id="1102">
                            <a href="${path}/User/student">学生信息管理</a>
                        </dd>
                        <dd id="1103">
                            <a href="${path}/Course/queryAll">课程信息管理</a>
                        </dd>
                    </dl>
                </li>
                <li>
                    <dl>
                        <dt id="1200">
                            <i class="icon-list-alt"></i>公告管理<i class="icon-angle-right"></i>
                        </dt>
                        <dd id="1201">
                            <a href="${path}/Notice/add">发布公告</a>
                        </dd>
                        <dd id="1202">
                            <a href="${path}/Notice/modify">公告修改</a>
                        </dd>
                        <dd id="1203">
                            <a href="${path}/Notice/delete">公告删除</a>
                        </dd>
                    </dl>
                </li>
                <li>
                    <dl>
                        <dt id="1300">
                            <i  class="icon-table"></i>课程管理<i class="icon-angle-right"></i>
                        </dt>
                        <dd id="1301">
                            <a href="${path}/Course/teacher">教师排课</a>
                        </dd>
                        <dd id="1302">
                            <a href="${path}/Course/student">学生选课</a>
                        </dd>
                        <dd id="1303">
                            <a href="${path}/Course/view">课表查看</a>
                        </dd>
                        <dd id="1304">
                            <a href="${path}/Course/suggeetion">学生反馈</a>
                        </dd>
                    </dl>
                </li>
                <li>
                    <dl>
                        <dt id="1400">
                            <i class="icon-bar-chart"></i>成绩信息<i class="icon-angle-right"></i>
                        </dt>
                        <dd id="1401">
                            <a href="${path}/Course/upload">上传成绩</a>
                        </dd>
                        <dd id="1402">
                            <a href="${path}/Course/queryCourse">成绩查询</a>
                        </dd>
                    </dl>
                </li>
                <li>
                    <dl>
                        <dt id="1500">
                            <i class="icon-external-link"></i>系统设置<i class="icon-angle-right"></i>
                        </dt>
                        <dd id="1501">
                            <a href="${path}/Role/queryAll">角色管理</a>
                        </dd>
                        <dd id="1502">
                            <a href="${path}/User/changePa">修改密码</a>
                        </dd>
                    </dl>
                </li>
            </ul>
        </nav>
        <footer class="side-footer">© DeathGhost 版权所有</footer>
    </div>
    <div class="content-wrap">
        <header class="top-hd">
            <div class="hd-lt">
                <a class="icon-reorder"></a>
            </div>
            <div class="hd-rt">
                <ul>
                    <li>
                        <a><i class="icon-user"></i>系统时间:<em>${Session["time"]}</em></a>
                    </li>
                    <li>
                        <a><i class="icon-user"></i>${Session["roleName"]}:<em>${Session["user"].name}</em></a>
                    </li>
                    <li>
                        <a onclick="quit();" ><i class="icon-signout"></i>安全退出</a>
                    </li>
                </ul>
            </div>
        </header>
        <main class="main-cont content mCustomScrollbar"> <!--开始::内容-->
            <div class="page-wrap">
                <section class="page-hd">
                    <header>
                        <h2 class="title">学生管理</h2>
                    </header>
                    <hr>
                </section>
                <form action="${path}/User/student" method="post">
                    <div class="form-group-col-2 " style="display: inline-block;" >
                        <div class="form-label">姓名：</div>
                        <div class="form-cont">
                            <input type="text" id="name11" name="name"  value=""  class="form-control form-boxed inputcs" style="width:200px">
                        </div>
                    </div>
                    <div class="form-group-col-2 " style="display: inline-block;">
                        <div class="form-label">联系方式：</div>
                        <div class="form-cont">
                            <input type="text" id="mobile12" name="mobile" value="" class="form-control form-boxed inputcs" style="width:200px">
                        </div>
                    </div>
                    <div class="form-group-col-2 " style="display: inline-block;">
                        <div class="form-cont">
                            <button class="btn btn-primary radius">搜索</button>
                        </div>
                    </div>
                </form>
                <div>
                    <button class="btn btn-danger radius" onclick="show2()">添加学生</button>
                </div>
                <table class="table table-bordered table-striped table-hover">
                    <thead>
                    <tr>
                        <th>编号</th>
                        <th>姓名</th>
                        <th>性别</th>
                        <th>联系方式</th>
                        <th>操作</th>
                    </tr>
                    </thead>
                    <tbody>

                    <#if list?exists>
                        <#list list as user>
                            <tr class="cen">
                            <td>${user["id"]}</td>
                            <td> ${user["name"]}</td>
                            <td> ${user["sex"]}</td>
                            <td> ${user["mobile"]}</td>
                            <td><a title="编辑" class="mr-5" onclick="show('${user["id"]}')">编辑</a>
                        <a title="详情" class="mr-5" onclick="show1('${user["id"]}')">详情</a>
                        <a title="删除" onclick="checkdel('${user["id"]}');">删除</a></td>
                            </tr>
                        </#list>
                    </#if>

                    </tbody>
                </table>

            </div>
        </main>
        <footer class="btm-ft">
            <p class="clear">
                <span class="fl">©Copyright 2016</span> <span class="fr text-info">
						<em class="uppercase"> <i class="icon-user"></i> management
							system
					</em>
					</span>
            </p>
        </footer>
    </div>
</div>
<div class="mask"></div>
<div class="dialog" style="width: 650px">
    <div class="dialog-hd">
        <strong class="lt-title">标题</strong> <a
                class="rt-operate icon-remove JclosePanel" title="关闭"></a>
    </div>
    <form action="" method="post">
        <div class="dialog-bd">
            <div class="form-group-col-2">
                <div class="form-label ">编号：</div>
                <div class="form-cont">
                    <input type="text" id="id1"
                           class="form-control form-boxed inputcs"  onblur="NcheckId(this);">
                </div>
            </div>
            <div class="form-group-col-2 ">
                <div class="form-label">姓名：</div>
                <div class="form-cont">
                    <input type="text" id="name1"
                           class="form-control form-boxed inputcs" onblur="NcheckName(this);">
                </div>
            </div>
            <div class="form-group-col-2">
                <div class="form-label">性别：</div>
                <div class="form-cont">
                    <label class="radio">
                        <input type="radio" name="sex" value="男"/>
                        <span>男</span>
                    </label>
                    <label class="radio">
                        <input type="radio" name="sex"  value="女"/>
                        <span>女</span>
                    </label>
                </div>
            </div>
            <div class="form-group-col-2">
                <div class="form-label">联系方式：</div>
                <div class="form-cont">
                    <input type="text" id="mobile1"
                           class="form-control form-boxed inputcs" onblur="NcheckM(this);">
                    <input type="hidden" id="flag">
                </div>
            </div>
            <div class="form-group-col-2">
                <div class="form-label">用户角色：</div>
                <div class="form-cont">
                    <select class="inputcs"  id="roleid1" >
                        <option value="">请选择</option>
                        <option value="0002">学生</option>
                    </select>
                </div>
            </div>


        </div>
    </form>
    <div class="dialog-ft" style="text-align: center; padding: -20px">
        <button type="submit" class="btn btn-info JyesBtn" id="submit11"
                onclick="subdata()">提交</button>
        <button class="btn btn-secondary JnoBtn">关闭</button>
    </div>
</div>

<div class="panel panel-default">
    <!--<div class="panel-hd">按钮</div>-->
    <div class="panel-bd">
        <button id="btnModify" class="btn btn-info JopenMaskPanel mr-10"></button>
    </div>
</div>


</body>
<script type="text/javascript">

    function NcheckId(th){
        if(th.value == ""){
            layer.alert("Id不能为空！");
        }
    }

    function NcheckName(th){
        if(th.value == ""){
            layer.alert("姓名不能为空！");
        }
    }

    function Ncheckd(th){
        if(th.value == ""){
            layer.alert("家庭住址不能为空！");
        }
    }

    function NcheckM(th){
        var myreg=/^[1][3,4,5,7,8][0-9]{9}$/;
        if (!myreg.test(th.value)) {
            layer.alert("手机号格式不正确！");
        }
    }

    function checkdel(id){
        if(confirm("你确定要删除吗？")){
            $.ajax({
                type: 'POST',
                url:"${path}/User/delete",
                dataType: 'json',
                cache: false,
                async:false,
                data:{ ID: id},
                success:function(data) {
                    window.location.reload();
                },
                error : function() {
                    window.location.reload();
                }
            });
        }
    }
    function subdata() {
        var flag = $("#flag").val();
        var id1  =  $("#id1").val();
        var name1  =  $("#name1").val();
        var sex1  =  $("input[name='sex']:checked").val();
        var mobile1  =  $("#mobile1").val();
        var address1  =  $("#address1").val();
        var roleid1  =  $("#roleid1").val();
        var localtion1  =  $("#localtion1").val();

        if (flag == "1") {
            //更新
            $.ajax({
                type : 'POST',
                url : "${path}/User/updateStudent",
                dataType : 'text',
                cache : false,
                async : false,
                data : {
                    id : id1,
                    name : name1,
                    sex : sex1,
                    mobile : mobile1,
                    address : address1,
                    localtion : localtion1,
                    roleid : roleid1
                },
                success : function(data) {
                    window.location.reload();
                },
                error : function() {
                    window.location.reload();
                }
            });

        } else if (flag == "2") {
            //查看

        } else if (flag == "3") {
            //新增
            $.ajax({
                type : 'POST',
                url : "${path}/User/addstudent",
                dataType : 'text',
                cache : false,
                async : false,
                data : {
                    id : id1,
                    name : name1,
                    sex : sex1,
                    mobile : mobile1,
                    address : address1,
                    localtion : localtion1,
                    roleid : roleid1
                },
                success : function(data) {
                    window.location.reload();
                },
                error : function() {
                    window.location.reload();
                }
            });
        }
    }

    //编辑展示
    function show(id) {
        $("#btnModify").click();
        $('#id1').attr("disabled", false);
        $('#name1').attr("disabled", false);
        $('#sex1').attr("disabled", false);
        $('#mobile1').attr("disabled", false);
        $('#address1').attr("disabled", false);
        $('#localtion1').attr("disabled", false);
        $('#roleid1').attr("disabled", false);
        $('#submit11').css("display","inline-block");
        $.ajax({
            type : 'POST',
            url : "${path}/User/queryOne",
            dataType : 'json',
            cache : false,
            async : false,
            data : {
                ID : id
            },
            success : function(data) {
                $("#id1").val(data.id);
                $("#name1").val(data.name);
                $(":radio[name='sex'][value='" + data.sex + "']").prop("checked", "checked");
                $("#mobile1").val(data.mobile);
                $("#address1").val(data.address);
                $("#localtion1").val(data.localtion);
                $("#roleid1").val(data.roleid);
                $("#flag").val("1");
            },
            error : function() {
                window.location.reload();
            }
        });
    }

    function show2() {
        $('#submit11').css("display","inline-block");
        $("#btnModify").click();
        $('#id1').attr("disabled", false);
        $('#name1').attr("disabled", false);
        $('#sex1').attr("disabled", false);
        $('#mobile1').attr("disabled", false);
        $('#address1').attr("disabled", false);
        $('#localtion1').attr("disabled", false);
        $('#roleid1').attr("disabled", false);
        $("#id1").val("");
        $("#name1").val("");
        $("#sex1").val("");
        $("#mobile1").val("");
        $("#address1").val("");
        $("#localtion1").val("");
        $("#roleid1").val("");
        $("#flag").val("3");
    }
    //查看展示
    function show1(id) {
        $("#btnModify").click();
        $.ajax({
            type : 'POST',
            url : "${path}/User/queryOne",
            dataType : 'json',
            cache : false,
            async : false,
            data : {
                ID : id
            },
            success : function(data) {
                $("#id1").val(data.id);
                $("#name1").val(data.name);
                $(":radio[name='sex'][value='" + data.sex + "']").prop("checked", "checked");
                $("#mobile1").val(data.mobile);
                $("#address1").val(data.address);
                $("#localtion1").val(data.localtion);
                $("#roleid1").val(data.roleid);
                $("#flag").val("2");
            },
            error : function() {
                window.location.reload();
            }
        });
        $('#id1').attr("disabled", true);
        $('#name1').attr("disabled", true);
        $('#sex1').attr("disabled", true);
        $('#mobile1').attr("disabled", true);
        $('#address1').attr("disabled", true);
        $('#localtion1').attr("disabled", true);
        $('#roleid1').attr("disabled", true);
        $('#submit11').css("display","none");
    }
    function quit(){
        if(confirm("你确定要退出登陆吗？")){
            window.location.href = "${path}/User/quit";
        }
    }
    //添加展示
</script>
</html>
